; IMPORTANT INFO ABOUT GETTING STARTED: Lines that start with a
; semicolon, such as this one, are comments.  They are not executed.

; This script has a special filename and path because it is automatically
; launched when you run the program directly.  Also, any text file whose
; name ends in .ahk is associated with the program, which means that it
; can be launched simply by double-clicking it.  You can have as many .ahk
; files as you want, located in any folder.  You can also run more than
; one .ahk file simultaneously and each will get its own tray icon.

; SAMPLE HOTKEYS: Below are two sample hotkeys.  The first is Win+Z and it
; launches a web site in the default browser.  The second is Control+Alt+N
; and it launches a new Notepad window (or activates an existing one).  To
; try out these hotkeys, run AutoHotkey again, which will load this file.

;^!n::
;IfWinExist Untitled - Notepad
;	WinActivate
;else
;	Run Notepad
;   MsgBox "Notepad opened"
;return

SetTitleMatchMode 2

Volume_Mute::
if WinExist("Microsoft Visual Studio")  {
	if WinActive("ahk_class #32770"){
		;;break debug IN VS2012
		Send !b
		;;detatch and reattach
		WinActive("Microsoft Visual Studio")
		Send +{F5}^!+{F5}
	}
	else
	if WinActive("Microsoft Visual Studio")
		if WinActive("(Running)") {
			Send +{F5}^!+{F5}
			Sleep 1000
			WinActive("Microsoft Visual Studio")
			Send ^!+{F5}
			WinActivate, ahk_class Shell_TrayWnd
			WinActive("Microsoft Visual Studio")
			Send ^!+{F5}
		}
		else {
			Send ^!+{F5}
		}
	else {
		WinActivate
	}
}
return


Media_Play_Pause::
if WinExist("Microsoft Visual Studio")  {
	if WinActive("Microsoft Visual Studio") 
		if WinActive("(Running) - Microsoft Visual Studio") or WinActive("(Debugging) - Microsoft Visual Studio") {
			Send +{F5}^b^!+{F5}
		}
		else {
			Send ^!+{F5}
		}
	else {
		WinActivate
	}
}
else {
	Run "c:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe"  
}
return

!Media_Play_Pause::
if WinExist("Microsoft Visual Studio")  {
	if WinActive("Microsoft Visual Studio") 
		if WinActive("(Running) - Microsoft Visual Studio") or WinActive("(Debugging) - Microsoft Visual Studio") {
			Send +{F5}^!b^!+{F5}
		}
		else {
			Send ^!+{F5}
		}
	else {
		WinActivate
	}
}
else {
	Run "c:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe"  
}
return

Volume_Up::
if WinExist("ahk_exe iexplore.exe") { 
	WinActivate, ahk_class IEFrame
}
else Run iexplore
return

Volume_Down::
if WinExist("ahk_exe chrome.exe") { 
	WinActivate, ahk_exe chrome.exe 
}
else Run chrome
return

$^+b::
SetTitleMatchMode 2
SendMode Input
if WinActive("Microsoft Visual Studio") {
	if WinActive("(Running) - Microsoft Visual Studio") or WinActive("(Debugging) - Microsoft Visual Studio") {

		Send +{F5}^+b^!+{F5}
		Sleep 1000
		WinActive("Microsoft Visual Studio")
		Send ^!+{F5}
		WinActivate, ahk_class Shell_TrayWnd
		WinActive("Microsoft Visual Studio")
		Send ^!+{F5}
	}
	else {
	   Send ^+b
	}
} else { 
   Send ^+b
}
return


$^!b::
SetTitleMatchMode 2
SendMode Input
if WinActive("Microsoft Visual Studio") {
	if WinActive("(Running) - Microsoft Visual Studio") or WinActive("(Debugging) - Microsoft Visual Studio") {

		Send +{F5}^!b^!+{F5}
		Sleep 1000
		WinActive("Microsoft Visual Studio")
		Send ^!+{F5}
		WinActivate, ahk_class Shell_TrayWnd
		WinActive("Microsoft Visual Studio")
		Send ^!+{F5}
	}
	else {
	   Send ^!b
	}
} else { 
   Send ^!b
}
return


$^b::
SetTitleMatchMode 2
SendMode Input
if WinActive("Microsoft Visual Studio") {
	if WinActive("(Running) - Microsoft Visual Studio") or WinActive("(Debugging) - Microsoft Visual Studio") {
		Send +{F5}^!b^!+{F5}
		Sleep 1000
		WinActive("Microsoft Visual Studio")
		Send ^!+{F5}
		WinActivate, ahk_class Shell_TrayWnd
		WinActive("Microsoft Visual Studio")
		Send ^!+{F5}
	}
	else {
	   Send ^b
	}
} else { 
   Send ^b
}
return


; Note: From now on whenever you run AutoHotkey directly, this script
; will be loaded.  So feel free to customize it to suit your needs.
